package com.guoyw.seata.business.controller;

import com.guoyw.seata.business.service.BusinessService;
import com.guoyw.seata.common.dto.BusinessDTO;
import com.guoyw.seata.common.response.ObjectResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Dubbo业务执行入口
 * author: guoyw
 * create: 2020-09-19 15:32
 **/
@RestController
@RequestMapping("/business/dubbo")
@Slf4j
public class BusinessController{
  
  @Autowired
  private BusinessService businessService;
  
  /**
   * 模拟用户购买商品下单业务逻辑流程
   * @Param:
   * @Return:
   */
  @PostMapping("/buy")
  ObjectResponse handleBusiness(@RequestBody BusinessDTO businessDTO){
    log.info("请求参数：{}",businessDTO.toString());
    return businessService.handleBusiness(businessDTO);
  }
  
  /**
   * 模拟用户购买商品下单业务逻辑流程
   * @Param:
   * @Return:
   */
  @PostMapping("/buy2")
  ObjectResponse handleBusiness2(@RequestBody BusinessDTO businessDTO){
    log.info("请求参数：{}",businessDTO.toString());
    return businessService.handleBusiness2(businessDTO);
  }
  
}
